/// @desc  日志输出
/// @time 2019/3/15 9:58 AM
/// @author Cheney
class LogUtil {

  static const String _TAG_Debug = "/debug/";
  static const String _TAG_Error = "/error/";

  ///是否 debug
  static bool debug = true; //是否是debug模式,true: log v 不输出.

  static void init({bool isDebug = false, String tag = _TAG_Debug}) {
    debug = isDebug;
    tag = tag;
  }


  static void p(Object object, {String tag= ""}) {
    if (debug) {
      _printLog(tag, object);
    }
  }
  static void e(Object object) {
    if (debug) {
      _printLog(_TAG_Error, object);
    }
  }

  static void _printLog(String tag, Object object) {
    StringBuffer sb = StringBuffer();
    sb.write((tag.isEmpty) ? _TAG_Debug : tag);
    sb.write(object);
    print(sb.toString());
  }
}
